<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        {:build_heading(null, false)}
        <ul class="nav nav-tabs">
            {volist name="app_type" id="vo"}
              <li {if condition="$key eq 0"} class="active" {/if}><a href="#type_{$vo.id}" data-toggle="tab">{$vo.name}</a></li>
            {/volist}
        </ul>
    </div>
    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            {volist name="app_type" id="vo"}
             <div class="tab-pane fade {if condition="$key eq 0"} active in {/if}" id="type_{$vo.id}" data-id="{$vo.id}">
                <form id="type_{$vo.id}_form" class="form-horizontal" method="POST" action="">
                    <div class="bootstrap-table">
                        <div class="fixed-table-container" style="padding-bottom: 0px;">
                            <div class="fixed-table-body">
                                <table id="type_{$vo.id}_table" class="table table-striped table-bordered table-hover" width="100%">
                                    <thead>
                                        <tr>
                                            <th style="text-align: center; vertical-align: middle; ">
                                                <div class="th-inner ">类目</div>
                                            </th>
                                            <th style="text-align: center; vertical-align: middle; ">
                                                <div class="th-inner ">技术选型及工期</div>
                                            </th>
                                        </tr>
                                        <tr>
                                            <th style="text-align: center; vertical-align: middle; ">
                                                <div class="th-inner ">后端技术</div>
                                            </th>
                                            <td>
                                                <div class="bootstrap-table">
                                                    <div class="fixed-table-container" style="padding-bottom: 0px;">
                                                        <div class="fixed-table-body">
                                                            <table  class="table table-striped table-bordered table-hover" width="100%">
                                                                <thead>
                                                                <tr>
                                                                    <th style="text-align: center; vertical-align: middle; ">
                                                                        <div class="th-inner ">功能名称</div>
                                                                    </th>
                                                                    <th style="text-align: center; vertical-align: middle; ">
                                                                        <div class="th-inner ">功能类型</div>
                                                                    </th>
                                                                    <th style="text-align: center; vertical-align: middle; ">
                                                                        <div class="th-inner ">技术选型</div>
                                                                    </th>
                                                                </tr>
                                                                <tr>
                                                                    <td style="text-align: center; vertical-align: middle;">
                                                                        {php}
                                                                          $gong=db('gongnen')->where('id',$gongnen['gid'])->find();
                                                                           echo $gong['name'];
                                                                         {/php}
                                                                    </td>
                                                                    <td style="text-align: center; vertical-align: middle;">
                                                                        <select class="form-control" name="budget_id">
                                                                            {volist name="budget_manage" id="bu"}
                                                                             <option value="{$bu.id}" {if condition="(!empty($vo['list'])) AND $bu['id'] eq $vo['list']['budget_id']"}selected{/if}>{$bu.name}</option>
                                                                            {/volist}
                                                                        </select>
                                                                    </td>
                                                                    <td style="text-align: center; vertical-align: middle;">

                                                                        <div class="bootstrap-table">
                                                                            <div class="fixed-table-container" style="padding-bottom: 0px;">
                                                                                <div class="fixed-table-body">
                                                                                    <table class="insert-tr table table-striped table-bordered table-hover onclick" width="100%">
                                                                                        <thead>
                                                                                        <tr>
                                                                                            <th style="text-align: center; vertical-align: middle; ">
                                                                                                <div class="th-inner ">应用语言</div>
                                                                                            </th>
                                                                                            <th style="text-align: center; vertical-align: middle; ">
                                                                                                <div class="th-inner ">工期（小时）</div>
                                                                                            </th>
                                                                                        </tr>
																					   {notempty name="vo['list']['technology']"}
																						 {volist name="vo['list']['technology']" id="item"}
                                                                                           <tr class="technology_language">
                                                                                             <td style="text-align: center; vertical-align: middle;">
                                                                                                <select class="form-control" name="tid" >
                                                                                                    {volist name="technology_language" id="th"}
                                                                                                      <option value="{$th.id}" {if condition="$th['id'] eq $item[0]"}selected{/if}>{$th.name}</option>
                                                                                                    {/volist}
                                                                                                </select>
                                                                                            </td>
                                                                                            <td class="copy" style="text-align: center; vertical-align: middle;">
                                                                                                <div class="col-xs-12 col-sm-8">
                                                                                                    <input class="form-control" type="number" name="time" value="{$item[1]}">
                                                                                                </div>
                                                                                                <div class="col-xs-12 col-sm-3">
                                                                                                    <a href="javascript:;" class="btn my-btn-add btn-success"><i class="fa fa-plus"></i></a>
                                                                                                    <a href="javascript:;" class="btn my-btn-del btn-danger"><i class="fa fa-trash"></i></a>
                                                                                                </div>
                                                                                            </td>
                                                                                         </tr>
																						{/volist}
																					  {else /}
																						  <tr class="technology_language">
                                                                                             <td style="text-align: center; vertical-align: middle;">
                                                                                                <select class="form-control" name="tid" >
                                                                                                    {volist name="technology_language" id="th"}
                                                                                                      <option value="{$th.id}">{$th.name}</option>
                                                                                                    {/volist}
                                                                                                </select>
                                                                                            </td>
                                                                                            <td class="copy" style="text-align: center; vertical-align: middle;">
                                                                                                <div class="col-xs-12 col-sm-8">
                                                                                                    <input class="form-control" type="number" name="time">
                                                                                                </div>
                                                                                                <div class="col-xs-12 col-sm-3">
                                                                                                    <a href="javascript:;" class="btn my-btn-add btn-success"><i class="fa fa-plus"></i></a>
                                                                                                    <a href="javascript:;" class="btn my-btn-del btn-danger"><i class="fa fa-trash"></i></a>
                                                                                                </div>
                                                                                            </td>
                                                                                         </tr>
																					   {/notempty}	
                                                                                        </thead>
                                                                                    </table>
                                                                                </div>
                                                                            </div>
                                                                        </div>

                                                                    </td>
                                                                </tr>
                                                                </thead>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                    </thead>
                                </table>
                                <div style="text-align:center;margin-top: 15px;">                                
                                    <span class="btn btn-success" id="submit">保存</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
             </div>
            {/volist}

        </div>
    </div>
</div>

<script>
    $(function(){
        $("#submit").click(function(){
            var items = new Array();
            var cheklist=$(".active.in").find(".technology_language");
            for (var i = 0; i < cheklist.length; i++) {
                var child_box=$(cheklist[i]);
                var tid=child_box.find("[name=tid]").val();
                var time=child_box.find("input[name=time]").val();
                var item=[tid,time];
                items.push(item);
            }
            var technology=JSON.stringify( items );

			var type_id=$(".active.in").attr('data-id');
            var gid="{$gongnen.id}";
            var tech_type=1;
            var budget_id=$(".active.in").find("input[name=budget_id]").val();
            $.ajax({
                type:'POST',
                data:{
				    type_id:type_id,
                    gid:gid,
                    tech_type:tech_type,
                    budget_id:budget_id,
                    technology:technology,
                },
                url:"{:url('gongjsave')}",
                traditional: true,
                success:function(data){
                    if(data.code==1){
                        alert(data.msg);
                        window.location.href=data.url;
                    }else{
                        alert(data.msg);
                    }
                }
            });
            return false;
        });

    })
</script>